import { http } from '@/utils/http/axios';

/**
 * 获取tree菜单列表
 * @param params
 */
export function serviceCategoryTree(params?) {
  return http.request({
    url: '/service/categories/tree',
    method: 'GET',
    params,
  });
}

/**
 * 添加菜单
 * @param params
 */
export function addServiceCategory(params?) {
  return http.request({
    url: '/service/categories',
    method: 'POST',
    params,
  });
}

/**
 * 编辑分类
 * @param params
 */
export function editServiceCategory(params?) {
  return http.request({
    url: `/service/categories/${params.id}`,
    method: 'PUT',
    params,
  });
}

/**
 * 获取分类
 * @param id
 */
export function serviceCategoryInfo(id) {
  return http.request({
    url: `/service/categories/${id}`,
    method: 'GET',
  });
}

/**
 * 删除分类
 * @param params
 */
export function deleteServiceCategory(id) {
  return http.request({
    url: `/service/categories/${id}`,
    method: 'DELETE',
  });
}

// 获取服务列表
export function getServiceList(params) {
  return http.request({
    url: '/service',
    method: 'GET',
    params,
  });
}

// 查询服务[根据id查询]
export function getService(id) {
  return http.request({
    url: `/service/${id}`,
    method: 'GET',
  });
}

// 新增服务
export function addService(params) {
  return http.request({
    url: `/service`,
    method: 'POST',
    params,
  });
}

// 更新服务
export function editService(params) {
  // 从params对象中提取id属性，并将剩余的属性收集到一个新对象中
  const { id, ...restParams } = params;
  return http.request({
    url: `/service/${id}`,
    method: 'PUT',
    params: restParams,
  });
}
